
//存储数据
function saveStorage(id) {
    var data = document.getElementById(id).value; //取值
    var time = new Date().getTime();
    localStorage.setItem(time, data); //保存
    alert("确定发表评论？");
    //localStorage('msg');
    loadStorage('msg');
}
//加载数据
function loadStorage(id) {
    var result = '<table id="table1" class="table table-hover">';
    for (var i = 0; i < localStorage.length; i++)
    {
        var key = localStorage.key(i);
        var value = localStorage.getItem(key); //读取
        var date = new Date();
        var spb = "&nbsp;"
        date.setTime(key);
        result += '<tr id="table2" class="active"><td><img src="pto/touxiang1.jpg"> </td><td>' + '第'+ (i+1) + '楼</td><td>'+ spb + spb  + value + '</td></tr>';
    }
    result += '</table>';
    var target = document.getElementById(id);
    target.innerHTML = result;
}
//清除数据
function clearStorage(id) {
    localStorage.clear();
    alert("数据已经被成功删除了！");
    loadStorage('msg');
}  